<?php
	include_once("config/config.inc.php");
	$templatepath='C:\\\\dpfps\\\\fpt\\\\';
	if($_POST["act"]=='scan') {
		$fp = fopen("C:/dpfps/Verification/pool/validate.txt","w");
		fwrite($fp, $templatepath . $_POST['user'].".fpt");
		fclose($fp);
		passthru("C:\PsTools\psexec ../fscan.bat");
	}elseif($_POST['act']=='monitor') {
		$resultfile = "C:/dpfps/Verification/pool/result.txt";
		$validatefile = "C:/dpfps/Verification/pool/validate.txt";
		if(file_exists($resultfile)) {
			$str = file_get_contents($resultfile);
			if(trim($str)=='verified') {
				
				$user=$_POST['user'];
				$sql="select userpass from users where username='$user'";
				$res = mysql_query($sql) or die(mysql_error());
				list($pass)=mysql_fetch_row($res);
				$ret = array("success"=>true, "pass"=>$pass);
				echo json_encode($ret);
			}
			
			unlink($validatefile);
			unlink($resultfile);
		}
	}
?>